<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>推广端会员列表</title>
    <link href="__PUBLIC__/home/css/bootstrap.min.css" rel="stylesheet">
    <link href="__PUBLIC__/home/css/alert.css" rel="stylesheet">
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <link href="__PUBLIC__/home/css/common.css" rel="stylesheet">
</head>

<body>
<div class="container-fluid">
    <!-- Page Heading -->
    <form class="form-inline" method="post" action="{:U('Member/index')}">
        <div class="form-group">
            <label for="exampleInputName2">总店列表</label>
            <select class="form-control" name="store_id" id="store_id">
                <option value="">请选择总店</option>
                <foreach name="storeList" item="s">
                    <option value="{$s.store_id}" <if condition="$store_id eq $s['store_id']">selected</if>>{$s.store_name}</option>
                </foreach>
            </select>
        </div>
        <div class="form-group">
            <label for="exampleInputName2">分店列表</label>
            <select class="form-control" name="store_parent_id" id="store_parent_id">
                <option value="">请选择分店</option>
                <foreach name="store_parentList" item="p">
                    <option value="{$p.store_id}" <if condition="$store_parent_id eq $p['store_id']">selected</if>>{$p.store_name}</option>
                </foreach>
            </select>
        </div>
        <div class="form-group">
            <label for="exampleInputName2">用户名</label>
            <input type="text" class="form-control" id="exampleInputName2" placeholder="请输入用户名" name="user_name" value="{$user_name}">
        </div>
        <div class="form-group">
            <label for="exampleInputName2">开始时间</label>
            <input type="text" name="start_time" id="test16" class="form-control" placeholder="点击选择开始时间" style="width: 180px;" readonly value="{$start_time}">
        </div>
        <div class="form-group">
            <label for="exampleInputName2">结束时间</label>
            <input type="text" name="end_time" id="test17" class="form-control" placeholder="点击选择结束时间" style="width: 180px;" readonly value="{$end_time}">
        </div>
        <button type="submit" class="btn btn-success">查询</button>
        <a href="{:U('Member/index')}" class="btn btn-warning">清空</a>
    </form>
    <div class="row">
        <div class="col-md-9">
            <label for="exampleInputName2">销售数据：</label>
            已成交数量：{$newArr.totalNumber}
            成交金额合计：{$newArr.totalTurnover}
        </div>
        <div class="col-md-9" >
            <label for="exampleInputName2">会员数据：</label>
            昨日新增会员:{$newArr.yesterdayCount}
            共新增会员：{$newArr.count}
            合计金额：{$newArr.totalSales}
        </div>
    </div>




    <div class="row">
        <div class="col-lg-12">
            <h2></h2>
            <div class="">
                <table class="table table-bordered table-hover table-striped" id="dataTables-date">
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>会员名称</th>
                        <th>会员手机号</th>
                        <th>注册时间</th>
                        <th>用户类型</th>
                        <th>注册类型</th>
                        <th>归属店铺</th>
                        <th>推荐人</th>
                        <th>已邀请人数</th>
                        <th>已成交数量</th>
                        <th>已成交金额</th>
                    </tr>
                    </thead>
                    <tbody>
                    <php>
                        $referType = array("0"=>'普通注册',"1"=>'分享注册',"2"=>'心愿单分享注册');
                    </php>
                    <foreach name="newArr['list']" item ="vo">
                        <php>
                            $referInfo = M("member")->where(array('user_id'=>$vo['referid']))->find();
                        </php>
                        <tr>
                            <td>{$vo.user_id}</td>
                            <td>{$vo.user_name}|{$vo.real_name}</td>
                            <td>{$vo.phone_mob}</td>
                            <td>{$vo.reg_time|date="Y-m-d H:i",###}</td>
                            <td>
                                <if condition="$vo['first_class'] neq 0 && $vo['third_class'] eq 0">员工
                                    <else/>
                                    用户
                                </if>
                            </td>
                            <td>{$referType[$vo['refer_type']]}</td>
                            <td>{$vo.s_name}</td>
                            <td>{$referInfo.user_name}|{$referInfo.real_name}</td>
                            <td>{$vo.register_number}</td>
                            <td>{$vo.totalNumber}</td>
                            <td>{$vo.totalTurnover}</td>
                        </tr>
                    </foreach>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <!-- /.row -->
    <div class="pages">
        {$page}
    </div>
</div>
<script src="__PUBLIC__/home/js/jquery.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="__PUBLIC__/home/js/bootstrap.min.js"></script>
<script src="__PUBLIC__/home/js/alert.js"></script>
<script src="__PUBLIC__/home/js/layer/layer.js"></script>
<script src="__PUBLIC__/home/js/laydate/laydate.js"></script>

<!-- iframe自适应高度 -->
</body>
<script type="text/javascript">
    laydate.render({
        elem: '#test16'
        ,type: 'datetime'
    });
    laydate.render({
        elem: '#test17'
        ,type: 'datetime'
    });

    $("button.btn-add").click(function () {
        location.href = "{:U('Store/insert')}";
    })
    $("button.btn-edit").click(function () {
        location.href = "{:U('Store/revise')}&store_id="+$(this).attr('attr-id');
    })

    $("#store_id").change(function(){
        var store_id = $(this).val();
        var url = "{:U('Member/getStore')}";
        if(store_id != ''){
            var str = '<option value="">请选择分店</option>'
            $.post(url,{
                store_id:store_id
            },function(data){
                var res = JSON.parse(data);
                if(res.length > 0){
                    $.each(res,function(index,item){
                        str += "<option value='"+item.store_id+"'>"+item.store_name+"</option>";
                    })
                }
                $("#store_parent_id").html(str);
            })
        }
    })
</script>

</html>
